function vertices = chooseBakeriesAlt(distances,wanderingDistances,eBarPrime,varargin);
% Choose where to locate bakeries

vertices = [0 0 0];
esize = max(size(distances));
setOne = zeros(2,10);
tolerance = 3;

idw = sum(wanderingDistances);
% now to choose multiple vertices, first one is where closest to target
[dist,indices] = sort(idw);

for j = 1:10
    setOne(1,j) = indices(1,j);
    setOne(2,j) = eBarPrime(indices(1,j));
end;

[C,I] = min(setOne(2,:));
vertices(1) = setOne(1,I(1,1));
i = 1;

% first we fill the second choice
for n = 2:esize
% If it is far away enough
    if(distances(indices(n),vertices(1)) >= tolerance)
        setTwo(1,i) = indices(n);
        setTwo(2,i) = eBarPrime(n);
        i = i + 1;
    end;
end;
[C,I] = min(setTwo(2,:));
vertices(2) = setTwo(1,I(1,1));   
i = 1;

%This is our third choice
for n = 2:esize
    if(distances(indices(n),vertices(1)) >= tolerance && distances(indices(n),vertices(2)) >= tolerance)
        setThree(1,i) = indices(n);
        setThree(2,i) = eBarPrime(n);
        i = i + 1;      
    end;
end;
[C,I] = min(setThree(2,:));
vertices(3) = setThree(1,I(1,1));


